#include "app_message.h"
#include "log.h"

int main(int argc, char const *argv[])
{   // 创建一个字节数组  
    char bytes[9] = {1 ,2,4,0x23,0x23,0x61,0x62,0x63,0x64};
    Message *message= app_message_bytes_to_message(bytes);

    char *json= app_message_message_to_json(message);
    log_info("json:%s",json);

    //a创建一个json字符串 
    //char *json_str = "{\"conn_type\":\"zhangsan\",\"age\":18,\"sex\":\"man\"}";
    Message *message2= app_message_json_to_message(json);
    log_info("message2:%d",message2->conn_type);
    int bytes_len;
    char *bytes2= app_message_message_to_bytes(message2,&bytes_len); 
    log_info("len:%d, bytes :%.*s",bytes_len,bytes_len,bytes2);
    for (size_t i = 0; i < bytes_len; i++)
    {
         printf("%02X ",bytes2[i]); 
    }
    printf("\n"); 

    return 0;
}
